home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
exec
/
writematch.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
6KB
|
188 lines
/* ***********************************************************************
WRITE MATCH PROGRAM FOR FOOTBALL REXX SUITE
---------------------------------------------
Copyright Mark Naughton 1997
Version Date History
--------------------------------------------------------------------------
1.0 080597 Created. Designed to be called from Gameplay to write
the score directly to the Schedule file, giving an
error if the match has been played, leaving Gameplay
to update the Learn file.
100597 Changed command for deleting the Game.Stored file. Had
to set 'sdcount' to 1 as lines were being missed in the
recreation as the first was being stored at 0 instead
of 1 which was where the loop started. Had to amend
the loop which wrote it back as it added one extra
line which wasn't required. Swapped parameters in the
'pos' statement when checking the matches as it was
always overwriting matches that had been played.
100697 Changed position that the away team is picked from the
argument to 1 from 2. Was giving invalid values.
Changed method again, a draw meant that the positions
picked up were one out as it went for the 1st occurrence.
1.1 240499 Jan Andersen reported a problem with teams with numerics
in their name and that the schedule was not being updated.
Reworked the code for updating the schedule - much better!
1.2 210899 Found bug in code which updates the match - Two similar
team names could not distinguish where they were in the
match arg - refused to write. Fixed.
250899 Added error msg to file check. Fixed bug where similar
team names confused the code which overwrote the wrong
match - the match is now split with "*" making it
easier to pase.
270899 Converted to use locale. Some error messages, before
reading the locale, will still be in English.
**************************************************************************
Procedure
---------
1. Split argument into league-name and match.
2. Check schedule file exists. If file-indicator exists then erase it.
3. Read Schedule file into an array.
4. Using the teams in the array, split into teams and use this as a match
against the teams from the game. When found, overwrite the scores.
5. If a match has been played and updated, then rewrite the Schedule file
back. Then write the file-indicator to tell Gameplay that a match has
been stored. Then exit.
************************************************************************** */
PARSE ARG league_file
version = 1
input_file = '.sf'
output_file = 'RAM:Game.stored'
separator = '*'
sdlines. = '???'
sdcount = 1
not_played = '__ __'
league_file = "Data/"league_file
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (WriteMatch)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
locdir = locdir"Exec/WriteMatch.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (WriteMatch)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
parse var league_file league " " match
parse var match tt1 "*" ss1 "*" ss2 "*" tt2
if exists(league || input_file) = 0 then do
say
say wm_error
say
say wm_one"'"league_file||input_file"'."
exit
end
if exists(output_file) > 0 then
address command 'delete >NIL: 'output_file
if open(datafile3,league || input_file,'r') then do
do while ~eof(datafile3)
line = readln(datafile3)
sdlines.sdcount = strip(line)
sdcount = sdcount + 1
end
close(datafile3)
end
else do
say
say wm_error
say
say wm_two"'"league || input_file"' "wm_three
exit
end
tt1 = strip(tt1)
tt2 = strip(tt2)
ss1 = strip(ss1)
ss2 = strip(ss2)
marker = 0
do i=1 to sdcount
team1 = strip(substr(sdlines.i,1,30))
team2 = strip(substr(sdlines.i,41,30))
if tt1 == team1 & tt2 == team2 then do
if pos(not_played,sdlines.i) > 0 then do
sdlines.i = overlay(right(ss1,2),sdlines.i,32)
sdlines.i = overlay(right(ss2,2),sdlines.i,37)
marker = 1
leave
end
else
marker = 0
end
end
if marker = 1 then do
if open(datafile3,league || input_file,'w') then do
do i=1 to sdcount-1
if i < sdcount-1 then
writeln(datafile3,sdlines.i)
else
writech(datafile3,sdlines.i)
end
close(datafile3)
if open(datafile1,output_file,'w') then do
writeln(datafile1,"Game stored in '"league||input_file"'.")
close(datafile1)
end
else do
say
say wm_error
say
say wm_five
exit
end
end
else do
say
say wm_error
say
say wm_two"'"league || input_file"' "wm_four
end
end
exit
/* *********************************************************************** */